
import pandas as pd

path1=r'E:\本地工作文档\Excel合并工具\excel_merge_2.xlsx'
path2=r'E:\本地工作文档\Excel合并工具\excel_merge_CP20230726046_A284_HAS_HK32_522B_NFT153000_NFT153000-01_CP1_20231001234832.xlsx'

def compare():
    excel1 = pd.read_excel(path1)
    excel2 = pd.read_excel(path2)
    diff =pd.concat([excel1,excel2]).drop_duplicates(keep=False)
    print(diff)
    diff.to_excel('diff.xlsx', index=False, header=True)

if __name__ == '__main__':
    compare()